﻿using System;
using System.Threading;

namespace csharpbiancheng_ch14_Thread_Sleep_example
{
    class Program
    {
        static void Main(string[] args)
        {
            ThreadStart ts1 = new ThreadStart(PrintEven);
            Thread t1 = new Thread(ts1);         
            ThreadStart ts2 = new ThreadStart(PrintOdd);
            Thread t2 = new Thread(ts2);         
            t1.Start();
            t2.Start();
        }


        //定义打印0-10中的偶数的方法
        private static void PrintEven()
        {
            for (int i = 1; i <= 10; i = i + 2)
            {
                //让线程休眠1秒
                Thread.Sleep(1000);
                Console.WriteLine(i);
            }
        }
        //定义打印0-10中的奇数的方法
        private static void PrintOdd()
        {
            for (int i = 0; i <= 10; i = i + 2)
            {
                Console.WriteLine(i);
                //让线程休眠1秒
                Thread.Sleep(1000);
            }
        }
    }
}
